﻿namespace Devonline.Entity;

/// <summary>
/// 附件, 只有对应实体附件才会有值, 字符串类型的默认实现
/// </summary>
[Table("attachment"), DisplayName("附件")]
public class Attachment : Attachment<string> { }

/// <summary>
/// 附件, 只有对应实体附件才会有值
/// </summary>
[Table("attachment"), DisplayName("附件")]
public abstract class Attachment<TKey> : EntitySetWithBusiness<TKey>, IAttachment<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 附件名
    /// </summary>
    [Column("name"), DisplayName("附件名"), Required, MaxLength(128), Excel]
    public virtual string? Name { get; set; }
    /// <summary>
    /// 文件大小
    /// </summary>
    [Column("length"), DisplayName("文件大小"), Excel]
    public virtual long Length { get; set; }
    /// <summary>
    /// 文件扩展名
    /// </summary>
    [Column("extension"), DisplayName("文件扩展名"), Required, MaxLength(16), Excel]
    public virtual string? Extension { get; set; }
    /// <summary>
    /// 文件的 content type
    /// </summary>
    [Column("content_type"), DisplayName("内容类型"), Required, MaxLength(128), Excel]
    public virtual string? ContentType { get; set; }
    /// <summary>
    /// 附件地址, 相对地址加上文件名
    /// </summary>
    [Column("path"), DisplayName("附件地址"), Required, MaxLength(256), Excel]
    public virtual string? Path { get; set; }
}